package cn.itcast.helloworld;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import android.widget.TextView;

import java.util.List;

public class MyAdapter extends ArrayAdapter<info> {

    private int resourceId;

    public MyAdapter(Context context, int textViewResourceId ,List<info> objects) {
        super(context,textViewResourceId,objects);
        resourceId = textViewResourceId;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        info ci = getItem(position);
        View view;
        if(convertView == null)
            view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        else
            view = convertView;

        TextView name = (TextView)view.findViewById(R.id.item_name) ;
        TextView phone = (TextView)view.findViewById(R.id.item_phone);
        name.setText(ci.getName());
        phone.setText(ci.getPhone());
        return view;
    }
}

